package cn.iocoder.yudao.module.polling.dal.mysql.pollingplan;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.polling.controller.admin.pollingcategories.vo.EquVo;
import cn.iocoder.yudao.module.polling.dal.dataobject.pollingplan.PollingPlanDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.polling.controller.admin.pollingplan.vo.*;

/**
 * 巡检计划 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface PollingPlanMapper extends BaseMapperX<PollingPlanDO> {

    default PageResult<PollingPlanDO> selectPage(PollingPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PollingPlanDO>()
                .betweenIfPresent(PollingPlanDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingPlanDO::getPlanCode, reqVO.getPlanCode())
                .likeIfPresent(PollingPlanDO::getPlanName, reqVO.getPlanName())
                .eqIfPresent(PollingPlanDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(PollingPlanDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PollingPlanDO::getPtType, reqVO.getPtType())
                .betweenIfPresent(PollingPlanDO::getPlanValidTime, reqVO.getPlanValidTime())
                .betweenIfPresent(PollingPlanDO::getPlanAdvanceTime, reqVO.getPlanAdvanceTime())
                .betweenIfPresent(PollingPlanDO::getPlanBeginTime, reqVO.getPlanBeginTime())
                .betweenIfPresent(PollingPlanDO::getPlanEndTime, reqVO.getPlanEndTime())
                .betweenIfPresent(PollingPlanDO::getPlanLastTime, reqVO.getPlanLastTime())
                .betweenIfPresent(PollingPlanDO::getPlanNextTime, reqVO.getPlanNextTime())
                .eqIfPresent(PollingPlanDO::getPlanEnable, reqVO.getPlanEnable())
                .eqIfPresent(PollingPlanDO::getPlanState, reqVO.getPlanState())
                .betweenIfPresent(PollingPlanDO::getPlanApproveEndTime, reqVO.getPlanApproveEndTime())
                .eqIfPresent(PollingPlanDO::getPlanPeriodVal, reqVO.getPlanPeriodVal())
                .eqIfPresent(PollingPlanDO::getPlanPeriodTitle, reqVO.getPlanPeriodTitle())
                .eqIfPresent(PollingPlanDO::getPlanValidTimeVal, reqVO.getPlanValidTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanAdvanceTimeVal, reqVO.getPlanAdvanceTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanRemindTimeVal, reqVO.getPlanRemindTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanNode, reqVO.getPlanNode())
                .betweenIfPresent(PollingPlanDO::getPlanExecuteTime, reqVO.getPlanExecuteTime())
                .eqIfPresent(PollingPlanDO::getPlanErrorCount, reqVO.getPlanErrorCount())
                .eqIfPresent(PollingPlanDO::getPlanMissingCount, reqVO.getPlanMissingCount())
                .orderByDesc(PollingPlanDO::getId));
    }

    default List<PollingPlanDO> selectList(PollingPlanExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PollingPlanDO>()
                .betweenIfPresent(PollingPlanDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingPlanDO::getPlanCode, reqVO.getPlanCode())
                .likeIfPresent(PollingPlanDO::getPlanName, reqVO.getPlanName())
                .eqIfPresent(PollingPlanDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(PollingPlanDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PollingPlanDO::getPtType, reqVO.getPtType())
                .betweenIfPresent(PollingPlanDO::getPlanValidTime, reqVO.getPlanValidTime())
                .betweenIfPresent(PollingPlanDO::getPlanAdvanceTime, reqVO.getPlanAdvanceTime())
                .betweenIfPresent(PollingPlanDO::getPlanBeginTime, reqVO.getPlanBeginTime())
                .betweenIfPresent(PollingPlanDO::getPlanEndTime, reqVO.getPlanEndTime())
                .betweenIfPresent(PollingPlanDO::getPlanLastTime, reqVO.getPlanLastTime())
                .betweenIfPresent(PollingPlanDO::getPlanNextTime, reqVO.getPlanNextTime())
                .eqIfPresent(PollingPlanDO::getPlanEnable, reqVO.getPlanEnable())
                .eqIfPresent(PollingPlanDO::getPlanState, reqVO.getPlanState())
                .betweenIfPresent(PollingPlanDO::getPlanApproveEndTime, reqVO.getPlanApproveEndTime())
                .eqIfPresent(PollingPlanDO::getPlanPeriodVal, reqVO.getPlanPeriodVal())
                .eqIfPresent(PollingPlanDO::getPlanPeriodTitle, reqVO.getPlanPeriodTitle())
                .eqIfPresent(PollingPlanDO::getPlanValidTimeVal, reqVO.getPlanValidTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanAdvanceTimeVal, reqVO.getPlanAdvanceTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanRemindTimeVal, reqVO.getPlanRemindTimeVal())
                .eqIfPresent(PollingPlanDO::getPlanNode, reqVO.getPlanNode())
                .betweenIfPresent(PollingPlanDO::getPlanExecuteTime, reqVO.getPlanExecuteTime())
                .eqIfPresent(PollingPlanDO::getPlanErrorCount, reqVO.getPlanErrorCount())
                .eqIfPresent(PollingPlanDO::getPlanMissingCount, reqVO.getPlanMissingCount())
                .orderByDesc(PollingPlanDO::getId));
    }

    List<PollingPlanInVo> selectPlanList(PollingPlanInVo pollingPlanInVo);

    List<PollingPlanInDao> selectDetailsList(PollingPlanInDao pollingPlanInDao);

    List<EquVo> selectUserByPlanId(int id);

}
